<script setup lang="ts">
import { getListByCondition } from '@/api/method';
import type { UtTechnique } from '@/types';
import { urls } from '@/utils';
import { useRequest } from 'vue-request';

const props = defineProps<{
  techniqueId: number;
  upddatable: boolean;
}>();

const {
  data: scanPlanData,
  run: getScanPlan,
  loading: getScanPlanLoading
} = useRequest(() =>
  getListByCondition<UtTechnique>(
    urls.techniqueUtTechniqueScanPlan,
    'techniqueId',
    props.techniqueId
  )
);
</script>
<template>
  <el-button-group>
    <el-button type="success" v-if="upddatable">新增</el-button>
    <el-button type="primary" @click="getScanPlan" :loading="getScanPlanLoading">更新</el-button>
  </el-button-group>
  <HqTable
    title="扫描计划"
    :base-url="urls.techniqueUtTechniqueScanPlan"
    :table-data="scanPlanData"
    :loading="getScanPlanLoading"
  >
    <template #columns>
      <HqTableColumn prop="direction" label="方向" :min-width="100" />
      <HqTableColumn prop="probeName" label="探头" :min-width="100" />
      <HqTableColumn prop="utBlock" label="试块" :min-width="100" />
      <HqTableColumn prop="referenceReflector" label="参考反射体" :min-width="100" />
      <HqTableColumn prop="scanNote" label="检测备注" :min-width="100" />
      <HqTableColumn label="操作" :min-width="100">
        <template #default="{ row }">
          {{ row.utBlock }}
        </template>
      </HqTableColumn>
    </template>
  </HqTable>
</template>
<style lang="scss" scoped>
.el-button-group {
  margin-bottom: 10px;
  > .el-button {
    margin-right: 5px;
    &:last-child {
      margin-right: 0;
    }
  }
}
</style>
